<template>
  <div id="XJHNT">
    <p style="text-align: center; margin: 10px 0">现浇混凝土结构质量检查和验收表</p>
    <table border="1" width="100%">
      <tr>
        <td>房屋验收层数</td>
        <td colspan="8">{{number}}</td>
      </tr>
      <tr>
        <th colspan="5">验收内容</th>
        <th>设计要求及规程规定</th>
        <!--<th>最小/实际抽样数量</th>-->
        <!--<th>检查记录</th>-->
        <th>检查结果</th>
      </tr>
      <tr>
        <td rowspan="5">主控项目</td>
      </tr>
      <tr>
        <td>1</td>
        <td colspan="3">钢筋的品种、级别、规格、数量</td>
        <td>
          第7.5.2条
          <br />显示
        </td>
        <!--<td>-->
        <!--<van-field v-model="form.CYSL1" placeholder="输入内容" />-->
        <!--</td>-->
        <!--<td>-->
        <!--<van-field v-model="form.JCJL1" placeholder="输入内容" />-->
        <!--</td>-->
        <td>
          <van-radio-group v-model="form.JCJG1">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field v-model="form.JCJG1" placeholder="输入内容" />-->
        </td>
      </tr>
      <tr>
        <td>2</td>
        <td colspan="3">混凝土原材料</td>
        <td>第7.5.3条</td>
        <!--<td>-->
        <!--<van-field v-model="form.CYSL2" placeholder="输入内容" />-->
        <!--</td>-->
        <!--<td>-->
        <!--<van-field v-model="form.JCJL2" placeholder="输入内容" />-->
        <!--</td>-->
        <td>
          <van-radio-group v-model="form.JCJG2">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field v-model="form.JCJG2" placeholder="输入内容" />-->
        </td>
      </tr>
      <tr>
        <td>3</td>
        <td colspan="3">混凝土配合比</td>
        <td>第7.5.3条</td>
        <!--<td>-->
        <!--<van-field v-model="form.CYSL3" placeholder="输入内容" />-->
        <!--</td>-->
        <!--<td>-->
        <!--<van-field v-model="form.JCJL" placeholder="输入内容" />-->
        <!--</td>-->
        <td>
          <van-radio-group v-model="form.JCJG3">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field v-model="form.JCJG3" placeholder="输入内容" />-->
        </td>
      </tr>
      <tr>
        <td>4</td>
        <td colspan="3">混凝土强度等级</td>
        <td>第7.5.3条</td>
        <!--<td>-->
        <!--<van-field v-model="form.CYSL4" placeholder="输入内容" />-->
        <!--</td>-->
        <!--<td>-->
        <!--<van-field v-model="form.JCJL4" placeholder="输入内容" />-->
        <!--</td>-->
        <td>
          <van-radio-group v-model="form.JCJG4">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field v-model="form.JCJG4" placeholder="输入内容" />-->
        </td>
      </tr>

      <tr>
        <td rowspan="7">一般项目</td>
      </tr>
      <tr>
        <td>1</td>
        <td colspan="3">混凝土养护和拆模时间</td>
        <td>第7.5.5条</td>
        <!--<td>-->
        <!--<van-field v-model="form.CYSL5" placeholder="输入内容" />-->
        <!--</td>-->
        <!--<td>-->
        <!--<van-field v-model="form.JCJL5" placeholder="输入内容" />-->
        <!--</td>-->
        <td>
          <van-radio-group v-model="form.JCJG5">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field v-model="form.JCJG5" placeholder="输入内容" />-->
        </td>
      </tr>
      <tr>
        <td>2</td>
        <td colspan="3">模板安装偏差</td>
        <td>第7.5.6条</td>
        <!--<td>-->
        <!--<van-field v-model="form.CYSL6" placeholder="输入内容" />-->
        <!--</td>-->
        <!--<td>-->
        <!--<van-field v-model="form.JCJL6" placeholder="输入内容" />-->
        <!--</td>-->
        <td>
          <van-radio-group v-model="form.JCJG6">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field v-model="form.JCJG6" placeholder="输入内容" />-->
        </td>
      </tr>
      <tr>
        <td>3</td>
        <td colspan="3">钢筋加工尺寸偏差</td>
        <td>第7.5.7条</td>
        <!--<td>-->
        <!--<van-field v-model="form.CYSL7" placeholder="输入内容" />-->
        <!--</td>-->
        <!--<td>-->
        <!--<van-field v-model="form.JCJL7" placeholder="输入内容" />-->
        <!--</td>-->
        <td>
          <van-radio-group v-model="form.JCJG7">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field v-model="form.JCJG7" placeholder="输入内容" />-->
        </td>
      </tr>
      <tr>
        <td>4</td>
        <td colspan="3">钢筋安装位置偏差</td>
        <td>第7.5.8条</td>
        <!--<td>-->
        <!--<van-field v-model="form.CYSL8" placeholder="输入内容" />-->
        <!--</td>-->
        <!--<td>-->
        <!--<van-field v-model="form.JCJL8" placeholder="输入内容" />-->
        <!--</td>-->
        <td>
          <van-radio-group v-model="form.JCJG8">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field v-model="form.JCJG8" placeholder="输入内容" />-->
        </td>
      </tr>
      <tr>
        <td>5</td>
        <td colspan="3">混凝土拌制和养护用水</td>
        <td>第7.5.9条</td>
        <!--<td>-->
        <!--<van-field v-model="form.CYSL9" placeholder="输入内容" />-->
        <!--</td>-->
        <!--<td>-->
        <!--<van-field v-model="form.JCJL9" placeholder="输入内容" />-->
        <!--</td>-->
        <td>
          <van-radio-group v-model="form.JCJG9">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field v-model="form.JCJG9" placeholder="输入内容" />-->
        </td>
      </tr>
      <tr>
        <td>6</td>
        <td colspan="3">现浇混凝土构件外观质量</td>
        <td>第7.5.10条</td>
        <!--<td>-->
        <!--<van-field v-model="form.CYSL10" placeholder="输入内容" />-->
        <!--</td>-->
        <!--<td>-->
        <!--<van-field v-model="form.JCJL10" placeholder="输入内容" />-->
        <!--</td>-->
        <td>
          <van-radio-group v-model="form.JCJG10">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field v-model="form.JCJG10" placeholder="输入内容" />-->
        </td>
      </tr>
      <tr>
        <td style="text-align: left; padding: 10px" colspan="4">施工单位（工匠）检查结果</td>
        <td colspan="5" style="text-align: left">
          <span style="float: left; margin-left: 8px">
            <van-field v-model="form.SGDWJCJG" placeholder="请填写检查人员" name="检查人员：" label="检查人员：" />
            <!-- <van-field v-model="form.SGDWJCJG" placeholder="输入内容" /> -->
          </span>
          <br />
          <br />
          <span style="float: left; margin-left: 8px">
            <van-field
              readonly
              clickable
              name="datetimePicker"
              :value="form.SGDWJCSJ"
              label="时间选择"
              placeholder="点击选择时间"
              @click="showPickerq = true"
            />
            <van-popup v-model="showPickerq" position="bottom">
              <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @cancel="showPickerq = false" @confirm="onConfirmRQ" />
            </van-popup>
          </span>
        </td>
      </tr>
      <tr>
        <td style="text-align: left; padding: 10px" colspan="4">业主（监理）验收结论</td>
        <td colspan="5" style="text-align: left">
          <span style="float: left; margin-left: 8px">
            <van-field v-model="form.YZYSJL" name="检查人员：" placeholder="请填写检查人员" label="检查人员：" />
            <!-- 检查人员：
            <van-field v-model="form.YZYSJL" placeholder="输入内容" />-->
          </span>
          <br />
          <br />
          <span style="float: left; margin-left: 8px">
            <van-field
              readonly
              clickable
              name="datetimePicker"
              :value="form.YZYSSJ"
              label="时间选择"
              placeholder="点击选择时间"
              @click="showPickerq1 = true"
            />
            <van-popup v-model="showPickerq1" position="bottom">
              <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @cancel="showPickerq1 = false" @confirm="onConfirmRQ1" />
            </van-popup>
          </span>
        </td>
      </tr>
      <tr>
        <td style="text-align: left; padding: 10px" colspan="8">
          <p>附件：</p>
          <p @click="seeFile" style="color: blue;">《农民自建低层住宅结构施工及验收规程》和条文说明</p>
        </td>
      </tr>
    </table>
    <div class="footer" v-if="!$route.query.type ||rowData.OPTYPE == '60'">
      <van-button v-if="!this.$store.state.isGJ||rowData.OPTYPE == '60'" size="small" type="info" @click="save">保存</van-button>
    </div>
  </div>
</template>
<style lang="scss">
#XJHNT {
  height: 100vh;
  overflow: auto;
  .van-radio__label {
    width: 48px;
  }
  /*padding:  10px;*/
  table,
  table tr th,
  table tr td {
    border: 1px solid #000000;
    text-align: center;
  }
  .footer {
    text-align: center;
    padding: 10px 0;
  }
}
</style>
<script>
import { updateDataView, dataServerOpenDataView, insertDataView, FileServerProxy } from '../../../utils/api'
import dd from 'gdt-jsapi'
export default {
  data() {
    return {
      number: '',
      radio: '',
      showPickerq: false,
      isTIjiao:false,
      showPickerq1: false,
      currentDate: new Date(),
      form: {
        row_guid: '',
        to_row_guid: '',
        CYSL1: '',
        CYSL2: '',
        CYSL3: '',
        CYSL4: '',
        CYSL5: '',
        CYSL6: '',
        CYSL7: '',
        CYSL8: '',
        CYSL9: '',
        CYSL10: '',
        JCJL1: '',
        JCJL2: '',
        JCJL: '',
        JCJL4: '',
        JCJL5: '',
        JCJL6: '',
        JCJL7: '',
        JCJL8: '',
        JCJL9: '',
        JCJL10: '',
        JCJG1: '1',
        JCJG2: '1',
        JCJG3: '1',
        JCJG4: '1',
        JCJG5: '1',
        JCJG6: '1',
        JCJG7: '1',
        JCJG8: '1',
        JCJG9: '1',
        JCJG10: '1',
        SGDWJCJG: '',
        SGDWJCR: '',
        SGDWJCSJ: '',
        YZYSJL: '',
        YZYSR: '',
        YZYSSJ: ''
      },
      isDataList: false
    }
  },
  methods: {
    seeFile() {
      dd.ready(function () {
        dd.openLink({
          url: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/文明.pdf'
        })
          .then(res => {
          })
          .catch(err => {
            console.error(err)
          })
      })
    },
    defaultField() {
      let dateTime
      let yy = new Date().getFullYear()
      let mm = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1
      let dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()
      dateTime = yy + '-' + mm + '-' + dd
      this.form.SGDWJCSJ = dateTime
      this.form.YZYSSJ = dateTime
    },
    //获取数据
    getData: async function () {
      // let dataGuid = "be302025-197c-455c-81ba-2018630bbd20";
      // let searchObject = encodeURIComponent(
      //   JSON.stringify([
      //     { field: "to_row_guid", value: this.rowData.ROW_GUID, operator: "=" },
      //   ])
      // );
      // let token = window.localStorage.getItem("token");
      // const res = await dataServerOpenDataView(dataGuid, searchObject, token);
      // if (res.data.Data && res.data.Data.length == 0) {
      //   //新增
      //   this.isDataList = false;
      // } else {
      //   //修该
      //   this.form = res.data.Data[0];
      //   this.form.SGDWJCSJ
      //     ? (this.form.SGDWJCSJ = this.form.SGDWJCSJ.split(" ")[0])
      //     : "";
      //   this.form.YZYSSJ
      //     ? (this.form.YZYSSJ = this.form.YZYSSJ.split(" ")[0])
      //     : "";
      //   this.isDataList = true;
      // }
      let params = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: 'be302025-197c-455c-81ba-2018630bbd20',
          searchObject: JSON.stringify([{ field: 'to_row_guid', value: this.rowData.ROW_GUID, operator: '=' }]),
          token: window.localStorage.getItem('token')
        }
      }
      const res = await FileServerProxy(params)
      let data = JSON.parse(res.data.data).Data
      if (data && data.length == 0) {
        //新增
        this.isDataList = false
      } else {
        //修该
        this.form = data[0]
        this.form.SGDWJCSJ ? (this.form.SGDWJCSJ = this.form.SGDWJCSJ.split(' ')[0]) : ''
        this.form.YZYSSJ ? (this.form.YZYSSJ = this.form.YZYSSJ.split(' ')[0]) : ''
        this.isDataList = true
      }
    },
    save: async function () {
      let data = this.form
      data.ROW_GUID = this.rowData.ROW_GUID
      data.to_row_guid = this.rowData.ROW_GUID
      // let params = {
      //   dataGuid: "be302025-197c-455c-81ba-2018630bbd20",
      //   strParams: JSON.stringify([data]),
      //   token: window.localStorage.getItem("token"),
      // };
      // if (!this.isDataList) {
      //   const res = await insertDataView(params);
      //   if (res.data.Success) {
      //     this.$toast.success('保存成功!');
      //   }
      // } else {
      //   const res = await updateDataView(params);
      //   if (res.data.Success) {
      //     this.$toast.success('保存成功!');
      //   }
      // }

      let params = {
        accessCode: '',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataGuid: 'be302025-197c-455c-81ba-2018630bbd20',
          strParams: JSON.stringify([data]),
          token: window.localStorage.getItem('token')
        }
      }
      if (!this.isDataList) {
        params.accessCode = '0fb3f6123d1b4fe6851c99532c463f6f'
        const res = await FileServerProxy(params)
        let data = JSON.parse(res.data.data).Success
        if (data) {
          this.$toast.success('成功！')
        }
      } else {
        params.accessCode = '77ad6c1591e54d4fbc45ecc90374a2a2'
        const res = await FileServerProxy(params)
        let data = JSON.parse(res.data.data).Success
        if (data) {
          this.$toast.success('修改成功!')
        }
      }
    },
    onConfirmRQ(val) {
      let year = val.getFullYear()
      let month = val.getMonth() + 1
      let day = val.getDate()
      let hour = val.getHours()
      let minute = val.getMinutes()
      if (month >= 1 && month <= 9) {
        month = `0${month}`
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`
      }
      this.className = 'timeClass'
      this.form.SGDWJCSJ = `${year}-${month}-${day}`
      this.showPickerq = false
    },
    onConfirmRQ1(val) {
      let year = val.getFullYear()
      let month = val.getMonth() + 1
      let day = val.getDate()
      let hour = val.getHours()
      let minute = val.getMinutes()
      if (month >= 1 && month <= 9) {
        month = `0${month}`
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`
      }
      this.className = 'timeClass'
      this.form.YZYSSJ = `${year}-${month}-${day}`
      this.showPickerq1 = false
    }
  },
  mounted() {
    this.defaultField()
    this.number = this.$route.query.number
    this.rowData = JSON.parse(this.$route.query.data)
    this.SaveData = JSON.parse(this.$route.query.data1)
    this.getData()
    if(window.localStorage.getItem('isPerTab') == 2){
      this.isTIjiao = false
    } else{
      this.isTIjiao = true
    }
  }
}
</script>
